package pe.com.cotelasa.seguridad.entidad;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
 
@Entity
@Table(name = "menu_rol",catalog = "bdcotelasa", schema = "seguridad")
@XmlRootElement
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
@NamedQueries({
    @NamedQuery(name = "MenuRol.findAll", query = "SELECT m FROM MenuRol m"),
    @NamedQuery(name = "MenuRol.findByIdRol", query = "SELECT m FROM MenuRol m WHERE m.menuRolPK.idRol = :idRol"),
    @NamedQuery(name = "MenuRol.findByIdMenu", query = "SELECT m FROM MenuRol m WHERE m.menuRolPK.idMenu = :idMenu"),
    @NamedQuery(name = "MenuRol.findByEstadoRegistro", query = "SELECT m FROM MenuRol m WHERE m.estadoRegistro = :estadoRegistro")})
public class MenuRol implements Serializable {

	private static final long serialVersionUID = -7126692085843330373L;

	@EmbeddedId
    protected MenuRolPK menuRolPK;
    
    @Basic(optional = false)
    @Column(name = "estado_registro")
    private char estadoRegistro;
    
    @JoinColumn(name = "id_menu", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(fetch=FetchType.LAZY)
    private Menu menu;

    public MenuRol() {
    }

    public MenuRol(MenuRolPK menuRolPK) {
        this.menuRolPK = menuRolPK;
    }

    public MenuRol(MenuRolPK menuRolPK, char estadoRegistro) {
        this.menuRolPK = menuRolPK;
        this.estadoRegistro = estadoRegistro;
    }

    public MenuRol(int idRol, int idMenu) {
        this.menuRolPK = new MenuRolPK(idRol, idMenu);
    }

    public MenuRolPK getMenuRolPK() {
        return menuRolPK;
    }

    public void setMenuRolPK(MenuRolPK menuRolPK) {
        this.menuRolPK = menuRolPK;
    }

    public char getEstadoRegistro() {
        return estadoRegistro;
    }

    public void setEstadoRegistro(char estadoRegistro) {
        this.estadoRegistro = estadoRegistro;
    }

    public Menu getMenu() {
        return menu;
    }

    public void setMenu(Menu menu) {
        this.menu = menu;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (menuRolPK != null ? menuRolPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MenuRol)) {
            return false;
        }
        MenuRol other = (MenuRol) object;
        if ((this.menuRolPK == null && other.menuRolPK != null) || (this.menuRolPK != null && !this.menuRolPK.equals(other.menuRolPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.com.cotelasa.seguridad.entidad.MenuRol[ menuRolPK=" + menuRolPK + " ]";
    }
    
}
